using com.youzu.warh.protocol;
using CustomDataStruct;
using ProtoBuf.Serializers;

namespace battle
{
    public class ArenaBattleReportDecorator: ICustomProtoSerializer
    {
        public void SetValue(object target, object value, int fieldNumber)
        {
            ArenaBattleReport data = target as ArenaBattleReport;
            if (data == null)
            {
                return;
            }

            switch (fieldNumber)
            {
                case 1:
                    data.reportId = (string) value;
                    break;
                case 2:
                    data.winnerId = ValueObject.Value<long>(value);
                    break;
                case 3:
                    data.reportSummary = (ArenaReportSummary) value;
                    break;
                case 4:
                    data.reportContent = (ArenaReportContent) value;
                    break;
            }
        }

        public object GetValue(object target, int fieldNumber)
        {
            ArenaBattleReport data = target as ArenaBattleReport;
            if (data == null)
            {
                return null;
            }

            switch (fieldNumber)
            {
                case 1:
                    return data.reportId;
                case 2:
                    return data.winnerId;
                case 3:
                    return data.reportSummary;
                case 4:
                    return data.reportContent;
            }

            return null;
        }
    }
}